package ch03;

public class Main {
    public static void main(String[] args) {
//        System.out.println(314);
//        System.out.println(3.14);
//        System.out.println(true);
//        System.out.println("true and false");
//        System.out.println(new AppleTree());
//        System.out.println(new Crop());
//        System.out.println(new Corn());

        Crop[] crops = new Crop[]{
                new AppleTree("富士"),
                new AppleTree("金帅"),
                new Corn(50),
                new Corn(100),
                new Pear("香水梨")
        };

        for (Crop crop:crops) {
            crop.print();
            if (crop instanceof AppleTree){
                AppleTree appleTree = (AppleTree)crop;
                appleTree.grafting("红粉佳人");
            }else if (crop instanceof Corn){
                Corn corn = (Corn) crop;
                corn.reHarvester(200);
            }else if (crop instanceof Pear){
                Pear pear = (Pear) crop;
                pear.grafting("贡梨");
            }
            crop.print();
        }
    }
}
